YPP_FILE=interpreterext
Y_FILE=programext

all: hw6
	
hw6:  
	bison $(YPP_FILE).ypp
	bison -d $(Y_FILE).y
	flex $(Y_FILE).l
	gcc -c lex.yy.c
	g++ $(YPP_FILE).tab.cpp $(Y_FILE).cpp lex.yy.o -o hw6

clean:
	rm -rf *o hw3*
	rm -rf *o hw6*
	rm -rf $(YPP_FILE).t*
	rm -rf $(Y_FILE).t*
	rm -rf lex.yy.c
	rm -rf samples/actual/*

test: clean hw6
	./hw6 30 < samples/add1-by-curry.p > samples/actual/add1-by-curry.txt
	diff -q  samples/expected/add1-by-curry.txt samples/actual/add1-by-curry.txt
	./hw6 30 < samples/add.p > samples/actual/add.txt
	diff -q  samples/expected/add.txt samples/actual/add.txt
	./hw6 30 < samples/addr.p > samples/actual/addr.txt
	diff -q  samples/expected/addr.txt samples/actual/addr.txt
	./hw6 30 < samples/assign-proc.p > samples/actual/assign-proc.txt
	diff -q  samples/expected/assign-proc.txt samples/actual/assign-proc.txt
	./hw6 30 < samples/assign-proc-and-call.p > samples/actual/assign-proc-and-call.txt
	diff -q  samples/expected/assign-proc-and-call.txt samples/actual/assign-proc-and-call.txt
	./hw6 30 < samples/ccc.p > samples/actual/ccc.txt
	diff -q  samples/expected/ccc.txt samples/actual/ccc.txt
#	./hw6 30 < samples/ccc-oper.p > samples/actual/ccc-oper.txt 
#	diff -q  samples/expected/ccc-oper.txt samples/actual/ccc-oper.txt
#	./hw6 30 < samples/compile-fail.p > samples/actual/compile-fail.txt
#	diff -q  samples/expected/compile-fail.txt samples/actual/compile-fail.txt
	./hw6 30 < samples/curry.p > samples/actual/curry.txt
	diff -q  samples/expected/curry.txt samples/actual/curry.txt
	./hw6 30 < samples/fact.p > samples/actual/fact.txt
	diff -q  samples/expected/fact.txt samples/actual/fact.txt
	./hw6 30 < samples/factorial.p > samples/actual/factorial.txt
	diff -q  samples/expected/factorial.txt samples/actual/factorial.txt
	./hw6 30 < samples/if.p > samples/actual/if.txt
	diff -q  samples/expected/if.txt samples/actual/if.txt
#	./hw6 30 < samples/make-double-oper.p > samples/actual/make-double-oper.txt
#	diff -q  samples/expected/make-double-oper.txt samples/actual/make-double-oper.txt
	./hw6 30 < samples/make-double-wrapper.p > samples/actual/make-double-wrapper.txt
	diff -q  samples/expected/make-double-wrapper.txt samples/actual/make-double-wrapper.txt
	./hw6 30 < samples/nested.p > samples/actual/nested.txt
	diff -q  samples/expected/nested.txt samples/actual/nested.txt
#	./hw6 30 < samples/pg170-3-19.p > samples/actual/pg170-3-19.txt
#	diff -q  samples/expected/pg170-3-19.txt samples/actual/pg170-3-19.txt
	./hw6 30 < samples/samplefile.p > samples/actual/samplefile.txt
	diff -q  samples/expected/samplefile.txt samples/actual/samplefile.txt
#	./hw6 30 < samples/scopetest.p > samples/actual/scopetest.txt
#	diff -q  samples/expected/scopetest.txt samples/actual/scopetest.txt
	./hw6 30 < samples/scoping.p > samples/actual/scoping.txt
	diff -q  samples/expected/scoping.txt samples/actual/scoping.txt
	./hw6 30 < samples/sepsteps.p > samples/actual/sepsteps.txt
	diff -q  samples/expected/sepsteps.txt samples/actual/sepsteps.txt
	./hw6 30 < samples/sepstepstest.p > samples/actual/sepstepstest.txt
	diff -q  samples/expected/sepstepstest.txt samples/actual/sepstepstest.txt
	./hw6 30 < samples/sepstepstest2.p > samples/actual/sepstepstest2.txt
	diff -q  samples/expected/sepstepstest2.txt samples/actual/sepstepstest2.txt
	./hw6 30 < samples/twostepa.p > samples/actual/twostepa.txt
	diff -q  samples/expected/twostepa.txt samples/actual/twostepa.txt
	./hw6 30 < samples/twostepb.p > samples/actual/twostepb.txt
	diff -q  samples/expected/twostepb.txt samples/actual/twostepb.txt
	./hw6 30 < samples/unnamed.p > samples/actual/unnamed.txt
	diff -q  samples/expected/unnamed.txt samples/actual/unnamed.txt
	./hw6 30 < samples/while.p > samples/actual/while.txt
	diff -q  samples/expected/while.txt samples/actual/while.txt
	./hw6 30 < samples/fact-unnamed.p > samples/actual/fact-unnamed.txt
	diff -q  samples/expected/fact-unnamed.txt samples/actual/fact-unnamed.txt
	./hw6 30 < samples/ccc-oneline.p > samples/actual/ccc-oneline.txt
	diff -q  samples/expected/ccc-oneline.txt samples/actual/ccc-oneline.txt
#	./hw6 30 < samples/ccc-oper-oneline.p > samples/actual/ccc-oper-oneline.txt
#	diff -q  samples/expected/ccc-oper-oneline.txt samples/actual/ccc-oper-oneline.txt
	
expected: clean hw3
	rm -rf samples/expected/*
	./hw6 30 < samples/add1-by-curry.p > samples/expected/add1-by-curry.txt
	./hw6 30 < samples/add.p > samples/expected/add.txt
	./hw6 30 < samples/addr.p > samples/expected/addr.txt
	./hw6 30 < samples/assign-proc.p > samples/expected/assign-proc.txt
	./hw6 30 < samples/assign-proc-and-call.p > samples/expected/assign-proc-and-call.txt
	./hw6 30 < samples/ccc.p > samples/expected/ccc.txt
#	./hw6 30 < samples/ccc-oper.p > samples/expected/ccc-oper.txt
#	./hw6 30 < samples/compile-fail.p > samples/expected/compile-fail.txt
	./hw6 30 < samples/curry.p > samples/expected/curry.txt
	./hw6 30 < samples/fact.p > samples/expected/fact.txt
	./hw6 30 < samples/factorial.p > samples/expected/factorial.txt
	./hw6 30 < samples/if.p > samples/expected/if.txt
#	./hw6 30 < samples/make-double-oper.p > samples/expected/make-double-oper.txt
	./hw6 30 < samples/make-double-wrapper.p > samples/expected/make-double-wrapper.txt
	./hw6 30 < samples/nested.p > samples/expected/nested.txt
#	./hw6 30 < samples/pg170-3-19.p > samples/expected/pg170-3-19.txt
	./hw6 30 < samples/samplefile.p > samples/expected/samplefile.txt
#	./hw6 30 < samples/scopetest.p > samples/expected/scopetest.txt
	./hw6 30 < samples/scoping.p > samples/expected/scoping.txt
	./hw6 30 < samples/sepsteps.p > samples/expected/sepsteps.txt
	./hw6 30 < samples/sepstepstest.p > samples/expected/sepstepstest.txt
	./hw6 30 < samples/sepstepstest2.p > samples/expected/sepstepstest2.txt
	./hw6 30 < samples/twostepa.p > samples/expected/twostepa.txt
	./hw6 30 < samples/twostepb.p > samples/expected/twostepb.txt
	./hw6 30 < samples/unnamed.p > samples/expected/unnamed.txt
	./hw6 30 < samples/while.p > samples/expected/while.txt
	./hw6 30 < samples/fact-unnamed.p > samples/expected/fact-unnamed.txt
	./hw6 30 < samples/ccc-oneline.p > samples/expected/ccc-oneline.txt
#	./hw6 30 < samples/ccc-oper-oneline.p > samples/expected/ccc-oper-oneline.txt

